package online.inote.naruto.api.access.admin.modules.login.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.FieldNameConstants;

import java.io.Serializable;

/**
 * @description 用户实体对象
 * @author XQF.Sui
 * @date 2021/07/26 15:50
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@FieldNameConstants
public class UserEntity implements Serializable {

  private static final long serialVersionUID = -1633822360779815565L;
  private static final String DEFAULT_ID = "naruto-security-administrator";

  private String id = DEFAULT_ID;
  private String username;
  private String password;
  /** 安全Key,每次登录都重新生成此Key,避免多个人同时登录 */
  private String securityKey;

  public static UserBuilder builder() {
    return new UserBuilder();
  }

  public static class UserBuilder {
    private String username;

    public UserBuilder username(String username) {
      this.username = username;
      return this;
    }

    public UserEntity build() {
      return new UserEntity(DEFAULT_ID, username, null, null);
    }
  }
}
